package com.lijiayuedaren.entity;

import java.util.List;

public class PageBean<T> {
    private int count ;//总条数
    private List<T> data;//这一页数据
    private int current; //当前页
    private int size; //每页条目数
    private int total; //总页数
    private  int first; //首页
    private int previous; //上一页
    private int next; //下一页

    public PageBean() {
    }

    public int getCount() {
        return count;
    }
    public List<T> getData(){
        return data;
    }
    public void setData(List<T> data){
        this.data = data;
    }

    public void setCount(int count) {
        this.count = count;
    }



    public int getCurrent() {
        return current;
    }

    public void setCurrent(int current) {
        this.current = current;
    }

    public int getSize() {
        return size;
    }

    public void setSize(int size) {
        this.size = size;
    }

    public int getTotal() {
        if (getCount()%getSize() == 0) {
            return getCount()/getSize();
        } else {
            return getCount()/getSize()+ 1;
        }

    }

    public void setTotal(int total) {
        this.total=total;
    }

    public int getFirst() {
        return 1;
    }

    public void setFirst(int first) {
        this.first = first;
    }

    public int getPrevious() {
        if (getCurrent() > 1) {
            return getCurrent() - 1;
        } else {
            return 1;
        }
    }

    public void setPrevious(int previous) {
        this.previous = previous;
    }

    public int getNext() {
        if (getCurrent() < getTotal()) {
            return getCurrent() + 1;
        } else {
            return getTotal();
        }
    }

    public void setNext(int next) {
        this.next = next;
    }

    @Override
    public String toString() {
        return "PageBean{" +
                "count=" + getCount() +
                ", data=" + getData() +
                ", current=" + getCurrent() +
                ", size=" + getSize() +
                ", total=" + getTotal() +
                ", first=" + getFirst() +
                ", previous=" + getPrevious() +
                ", next=" + getNext() +
                '}';
    }
}

